import { createBrowserRouter } from 'react-router-dom'
import Root from '@/views/root'
import Home from '@/views/home'
import Movie, { loader as movieLoader } from '@/views/movie'
import About from '@/views/about'

const router = createBrowserRouter([
  {
    path: '/',
    element: <Root />,
    children: [
      { index: true, element: <Home /> },
      { path: 'home', element: <Home /> },
      // 使用 loader 选项为路由规则挂载 movieLoader 处理函数
      { path: 'movie', element: <Movie />, loader: movieLoader },
      { path: 'about', element: <About /> }
    ]
  }
])

export default router
